package net.xiaosaguo.mymall.product.web;

import net.xiaosaguo.mymall.product.service.SkuInfoService;
import net.xiaosaguo.mymall.product.vo.SkuItemVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * description: 商品详情页
 *
 * @author xiaosaguo
 * @date 2020/07/02
 */
@Controller
public class ItemController {

    @Autowired
    SkuInfoService skuInfoService;

    @GetMapping("/{skuId}.html")
    public String item(@PathVariable Long skuId, Model model) throws ExecutionException, InterruptedException {

        System.out.println("准备查询" + skuId + "的详情");
        SkuItemVO vo = skuInfoService.item(skuId);
        model.addAttribute("item", vo);
        return "item";
    }
}
